#define _CRT_SECURE_NO_WARNINGS 1

#include "List.h"

void ListTest1()
{
	LTNode* plist = ListInit();
	ListPushBack(plist, 1);
	ListPushBack(plist, 2);
	ListPushBack(plist, 3);
	ListPushBack(plist, 4);

	ListPrint(plist);

	ListPopBack(plist);
	ListPopBack(plist);

	ListPrint(plist);

	ListPopBack(plist);

	ListPrint(plist);

}

void ListTest2()
{
	LTNode* plist = ListInit();
	ListPushFront(plist, 1);
	ListPushFront(plist, 2);
	ListPushFront(plist, 3);
	ListPushFront(plist, 4);

	ListPrint(plist);

	ListPopFront(plist);
	ListPopFront(plist);

	ListPrint(plist);
}

void ListTest3()
{
	LTNode* plist = ListInit();
	ListInsert(plist, 1);
	ListPrint(plist);

	ListPushBack(plist, 2);
	ListPushBack(plist, 3);
	ListPushBack(plist, 4);

	ListPrint(plist);

	LTNode* pos1 = ListFind(plist, 3);
	if (pos1)
	{
		ListInsert(pos1, 30);
	}
	ListPrint(plist);

	ListInsert(plist, 40);
	ListInsert(plist->next, 10);

	ListPrint(plist);
}

void ListTest4()
{
	LTNode* plist = ListInit();
	ListPushBack(plist, 1);
	ListPushBack(plist, 2);
	ListPushBack(plist, 3);
	ListPushBack(plist, 4);
	ListPushBack(plist, 5);

	ListErase(plist->next);
	ListErase(plist->prev);

	ListPrint(plist);

	LTNode* pos1 = ListFind(plist, 3);
	if (pos1)
	{
		ListErase(pos1);
	}
	ListPrint(plist);
}

void ListTest5()
{
	LTNode* plist = ListInit();
	ListPushBack(plist, 1);
	ListPushBack(plist, 2);
	ListPushBack(plist, 3);
	ListPushBack(plist, 4);

	ListPrint(plist);

	ListDestory(&plist);
}

int main()
{
	//ListTest1();
	//ListTest2();
	//ListTest3();
	//ListTest4();
	ListTest5();
	return 0;
}